<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/denglu.css" />
</head>

<body>
    <div id="top">
        <img src="img/images/pic.png">
    </div>
    <div id="hoder">
        <div id="hoder-con">
            <img src="img/images/logo.png"><br>
            <span class="one">登录&nbsp;&nbsp;&nbsp;</span>
            <span class="two">&nbsp;&nbsp;原官网账号登录&nbsp;&nbsp;</span>
            <span class="three"><img src="img/images/images/登录_031.png" ></span>
            <p>
                <input type="text" id="username" placeholder="请输入账号">
            </p>
            <p>
                <input type="password" id="password" placeholder="请输入密码">
            </p>
            <p class="nikin">
                <input type="checkbox" id="autologin">
                <label for="autologin">十天内免登陆</label>
                <span id="kin">
					忘记密码？
					</span>
            </p>
            <p>
                <button id="login">立即登录</button>
            </p>
            <p class="nfn">
                还没有账号？？<a href="zhuce.html">去注册</a>
            </p>
        </div>
    </div>
</body>

</html>
<script src="jquery.min.js"></script>
<script>
    $(function() {
        let username = localStorage.getItem("username");
        let password = localStorage.getItem("password");
        if (username && password) {
            $("#username").val(username)
            $("#password").val(password)
            $("#login").click()
        }
    })
    $("#login").click(function() {
        let username = $("#username").val()
        let password = $("#password").val()

        if ((username && password)) {
            $.ajax({
                url: "http://10.35.162.123:8080/denglu",
                data: {
                    username: username,
                    password: password
                },
                success(data) {
                    if (data === "success") {
                        alert("登录成功")
                        if ($("#autologin").prop("checked")) {
                            localStorage.setItem("username", username)
                            localStorage.setItem("password", password)
                        }
                        location.href = "http://10.35.162.123/jinlixiangmu/index.html"
                    } else {
                        alert("用户名或密码错误")
                    }
                }
            })
        } else {
            alert("请正确输入")
        }
    })
</script>